//
//  ACEStudentDetailListHeaderView.m
//  ACE
//
//  Created by zhangtao on 2018/8/9.
//  Copyright © 2018年 zt.td. All rights reserved.
//

#import "ACEStudentDetailListHeaderView.h"

@implementation ACEStudentDetailListHeaderView

-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = [UIColor whiteColor];
        _headImgV = [[UIImageView alloc]initWithFrame:CGRectMake(self.center.x-30, 10, 60, 60)];
        [self addSubview:_headImgV];
        
        _headImgV.layer.cornerRadius = 30;
        _headImgV.layer.masksToBounds = YES;
        _headImgV.image = [UIImage imageNamed:@"placeholdimg2"];
        
        _nameLab = [[UILabel alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(_headImgV.frame)+10, self.frame.size.width, 15)];
        [self addSubview:_nameLab];
        _nameLab.font = [UIFont systemFontOfSize:17];
        _nameLab.text = @"PRO.A.C";
        _nameLab.textAlignment = NSTextAlignmentCenter;
        _desLab = [[UILabel alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(_nameLab.frame)+10, self.frame.size.width, 15)];
        [self addSubview:_desLab];
        _desLab.font = [UIFont systemFontOfSize:14];
        _desLab.text = @"语言/英语/方言";
        _desLab.textAlignment = NSTextAlignmentCenter;
        _desLab.textColor = [UIColor darkGrayColor];
        
        _starView = [[ACEStarView alloc]initWithFrame:CGRectMake(120, CGRectGetMaxY(_desLab.frame)+10, ACEWidth-240, 20)];
        [self addSubview:_starView];
        
        _commentBtn = [[UIButton alloc]initWithFrame:CGRectMake(frame.size.width/2-120, frame.size.height-35, 100, 30)];
        [_commentBtn setTitle:@"学生评价" forState:UIControlStateNormal];
        [_commentBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [_commentBtn setTag:1];
        [_commentBtn addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:_commentBtn];
        
        _desBtn = [[UIButton alloc]initWithFrame:CGRectMake(frame.size.width/2+20, frame.size.height-35, 100, 30)];
        [_desBtn setTitle:@"课程描述" forState:UIControlStateNormal];
        [_desBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [_desBtn setTag:2];
        [_desBtn addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];

        [self addSubview:_desBtn];
        
    }
    return self;
}

-(void)click:(UIButton *)btn{
    if (self.DetailListSoowStateCallBack) {
        self.DetailListSoowStateCallBack(btn.tag);
    }
    
    [btn setTitleColor:deepGreen forState:UIControlStateNormal];
    
    if (btn == _desBtn) {
        [_commentBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    }else{
        [_desBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    }
}

-(void)setStarNum:(NSInteger)starNum{
    
    _starView.starNum = starNum;
}

-(void)setShowState:(NSString *)showState{
    if ([showState isEqualToString:@"1"]) {
        [_commentBtn setTitleColor:deepGreen forState:UIControlStateNormal];
    }else{
        [_desBtn setTitleColor:deepGreen forState:UIControlStateNormal];

    }
}


/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect {
 // Drawing code
 }
 */

@end



